﻿/**这里是一些初始化配置*/
//配置颜色，必须放在初始化下面
GooFlow.prototype.color={
  main:"#A8C508",
  node:"#F9F9F9",//节点背景颜色
  nodeBorder:"#008CD6",//节点边框未被选中时的颜色
  focus:"#FF9900",//节点被选中时的边框颜色
  line:"#008CD6",
  mark:"#E98200",
  mix:"#008CD6",
  font:"#2A2A2A"
};
var property={//节点
	width:jQuery(window).width(),
	height:jQuery(window).height(),
	headHeight:50,
	toolWidth:0,
	useOperStack:true
};
var remark={//节点注释
	"cursor":"选择指针",
	"line":"连线",
	"start":"开始",
	"end":"结束",
	"apply":"提出申请",
	"single":"审批",
	"multiple":"会签",
	"judge":"判断",
	"route":"路由",
	"script":"脚本事件",
	"subflow":"子流程",
	"timer":"定时事件",
	"message":"消息事件"
};
//窗口大小变动的时候
jQuery(window).resize(function(){
	setDrawHeight($(window).height());//窗口高度减去demo栏高度
	setDrawWidth($(window).width());
});
//设置绘图区高度（不包含顶栏）
function setDrawHeight(h){
	if(h>200){//如果小于200像素，则不再进行调整
		$("#items").height(h+"px");
		$("#flow_form").height(h-50+"px");//再去掉操作栏高度
		$("#demo").height("100%");
		var main_height = h-50;//主体绘图区高度
		$(".GooFlow_work").height("100%");
		$(".GooFlow_tool_div").height(main_height+"px");
		$(".draw_demo").height(main_height+"px");
		$("#ele_sssd").val(h);
	}
}
//设置绘图区宽度
function setDrawWidth(w){
	if(w>300){//如果小于300+300像素，则不再进行调整
		$("#demo").width("100%");
		$(".GooFlow_work").width("100%");
	}
}

//根据节点类型名称获取信息
//name包括start,end,apply,single,multiple,judge,route,script,subflow,timer,message,line
//type包括：itemRemark:节点中文名称；itemCode:节点对应编号
function getObjByName(name,type){
	if(type=="itemRemark"){
		switch(name){
			case "start":	return remark.start;break;
			case "start round":	return remark.start;break;//这两个是针对圆形图标特殊情况
			case "end":		return remark.end;break;
			case "end round":	return remark.end;break;
			case "apply":	return remark.apply;break;
			case "single":	return remark.single;break;
			case "multiple":return remark.multiple;break;
			case "judge":	return remark.judge;break;
			case "route":	return remark.route;break;
			case "line":	return remark.line;break;
			case "script":	return remark.script;break;
			case "subflow":	return remark.subflow;break;
			case "timer":	return remark.timer;break;
			case "message":	return remark.message;break;
			case "sl":		return remark.line;break;//这三个是针对线的特殊情况
			case "lr":		return remark.line;break;
			case "tb":		return remark.line;break;
		}
	}else if(type=="itemCode"){
		switch(name){
			case "start":	return "0";break;
			case "end":		return "1";break;
			case "apply":	return "2";break;
			case "single":	return "3";break;
			case "multiple":return "4";break;
			case "judge":	return "5";break;
			case "route":	return "6";break;
			case "line":	return "7";break;
			case "script":	return "8";break;
			case "subflow":	return "9";break;
			case "timer":	return "10";break;
			case "message":	return "11";break;
		}
	}else if(type=="codetoName"){//根据code获取名称
		switch(name){
			case "0":	return remark.start;break;
			case "1":	return remark.end;break;
			case "2":	return remark.apply;break;
			case "3":	return remark.single;break;
			case "4":	return remark.multiple;break;
			case "5":	return remark.judge;break;
			case "6":	return remark.route;break;
			case "7":	return remark.line;break;
			case "8":	return remark.script;break;
			case "9":	return remark.subflow;break;
			case "10":	return remark.timer;break;
			case "11":	return remark.message;break;
		}
	}else if(type=="codetoItem"){//根据code获取画图器内节点名
		switch(name){
			case "0":	return "start";break;
			case "1":	return "end";break;
			case "2":	return "apply";break;
			case "3":	return "single";break;
			case "4":	return "multiple";break;
			case "5":	return "judge";break;
			case "6":	return "route";break;
			case "7":	return "line";break;
			case "8":	return "script";break;
			case "9":	return "subflow";break;
			case "10":	return "timer";break;
			case "11":	return "message";break;
		}
	}else if(type=="itemType"){//根据节点获取模板中的类型（node,line,area)
		switch(name){
		case "start":		return "node";break;
		case "start round":	return "node";break;//这两个是针对圆形图标特殊情况
		case "end":			return "node";break;
		case "end round":	return "node";break;
		case "apply":		return "node";break;
		case "single":		return "node";break;
		case "multiple":	return "node";break;
		case "judge":		return "node";break;
		case "route":		return "node";break;
		case "line":		return "line";break;
		case "script":		return "node";break;
		case "subflow":		return "node";break;
		case "timer":		return "node";break;
		case "message":		return "node";break;
		case "sl":			return "line";break;//这三个是针对线的特殊情况
		case "lr":			return "line";break;
		case "tb":			return "line";break;
	}
}
	return false;
}